package com.gin.kotlin.no_gay_alliance.runner

import android.widget.ImageView
import com.bumptech.glide.Glide
import com.gin.kotlin.no_gay_alliance.app.App
import com.gin.kotlin.no_gay_alliance.app.AppRunner
import com.wgw.photo.preview.PhotoPreview

/**
 * PhotoPreview初始化
 */
class PhotoPreviewRunner:AppRunner{
    /**
     * 执行的任务内容
     * @param app [App]
     */
    override fun run(app: App) {
        // 为图片预览框架配置全局图片加载器
        PhotoPreview.setGlobalImageLoader { _: Int, source: Any?, imageView: ImageView ->
//            if (source is ImageUtils.PreviewSource) {
//                Glide.with(imageView.context).load((source as ImageUtils.PreviewSource?).getPreviewUrl()).into(imageView)
//            }
            if (source is String) {
                Glide.with(imageView.context).load(source.toString()).into(imageView)
            }
        }
    }
}